package com.rzjm.exercise.common.utils.encryp.impl;

import java.util.Base64;

import com.rzjm.exercise.common.utils.encryp.Encryp;
import org.springframework.stereotype.Component;

@Component
public class EncrypBase64 implements Encryp {

	@Override
	public String encrytor(String str) {
		return toEncodedString(Base64.getEncoder().encode(str.getBytes(charset)));
	}

	@Override
	public String decryptor(String str) {
		return toEncodedString(Base64.getDecoder().decode(str.getBytes(charset)));
	}
	
	/**
	 * @param args
	 */
	public static void main(String[] args) throws Exception {
		Encryp des = new EncrypBase64();
		String msg ="搞笑相声全集";
		String encontent = des.encrytor(msg);
		String decontent = des.decryptor(encontent);
		System.out.println("明文是:" + msg);
		System.out.println("加密后:" + encontent);
		System.out.println("解密后:" + decontent);
		
		System.out.println("5pCe56yR55u45aOw5YWo6ZuG".length());
	}
}
